import java.util.InputMismatchException;
import java.util.Scanner;

public class CalendarSeeker {
    public static void main(String args[]) {
        int day;
        int month;
        int year;
        Scanner in = new Scanner(System.in);

        try {
            System.out.println("Input date using format: dd Month yyyy");
            day = in.nextInt();
            month = getMonthNumber(in);
            year = in.nextInt();
            validateDateInput(day, month, year);
            System.out.println(getDayOfWeek(day, month, year));
        } catch (InputMismatchException e) {
            System.out.println("Wrong date format");
        } finally {
            in.close();
        }
    }

    /**
     * Powered by http://www.genon.ru/GetAnswer.aspx?qid=0fecaff5-4fd3-4c96-ac83-4b80e91d4afe
     * It looks strange, but works fine.
     */
    private static String getDayOfWeek(int day, int month, int year) {
        final int MONTHS_IN_YEAR = 12;
        final int MAX_DAYS_IN_MONTH = 31;
        final int DAYS_IN_MONTH_CORRECTION = 10;
        final int DAYS_IN_WEEK = 7;
        String[] daysOfWeekNames = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
        int dayOfWeekNumber;
        int leapYearsCorrection;

        if (month <= 2) {
            year--;
            day += 3;
        }
        leapYearsCorrection = getLeapCorrection(month, year);
        dayOfWeekNumber = (day + year + leapYearsCorrection
                + (MAX_DAYS_IN_MONTH * month + DAYS_IN_MONTH_CORRECTION) / MONTHS_IN_YEAR)
                % DAYS_IN_WEEK;
        return daysOfWeekNames[dayOfWeekNumber];
    }

    private static boolean isLeap(int year) {
        return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
    }

    /**
     * It isn't necessary to validate number of days in month, because even if there is 31 days, and
     * you input 35, answer will be correct as for 31 days + 4 of next month.
     */
    private static void validateDateInput(int day, int month, int year) throws InputMismatchException {
        final int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        month--;
        if ((isLeap(year)) && (month == 1)) {
            if (day > daysInMonth[month] + 1) {
                throw new InputMismatchException();
            }
        } else if (day < 0 || month < 0 || year < 0 || day > daysInMonth[month]) {
            throw new InputMismatchException();
        }
    }

    private static int getLeapCorrection(int month, int year) {
        int leapYearsCorrection = year / 4 - year / 100 + year / 400;

        if ((month <= 2) && isLeap(year)) {
            leapYearsCorrection--;
        }
        return leapYearsCorrection;
    }

    private static int getMonthNumber(Scanner in) {
        String monthName = in.next();
        String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August",
                "September", "October", "November", "December"};

        for (int i = 0; i < monthNames.length; i++) {
            if (monthName.equals(monthNames[i])) {
                return i + 1;
            }
        }
        return 0;
    }
}